package com.woniuxy01;

/**
 * @author 作者
 * @create 2025-09-02 11:09
 */
public class Test02 {
    public static void main(String[] args) {
        //对象数组：学生数组
        Student[] students = new Student[2];
        //数组的第一个学生分配空间
        students[0] = new Student();
        //数组的第一个学生属性赋值
        students[0].name="zs";
        System.out.println(students[0].show());

        Student student2=new Student();
        student2.name="ls";
        students[1]=student2;
        System.out.println(students[1].show());
        System.out.println(student2.show());
        System.out.println("对象数组遍历1");
        for(int i=0;i<students.length;i++){
//            System.out.println(students[i].show());
            Student student=students[i];
            System.out.println(student.show());
        }
        System.out.println("对象数组遍历2");
//        int[] a={1,2,3};
//        for(int i : a)

        for(Student student:students){
            System.out.println(student.show());
        }
    }
}
